home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 488 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  806 b 

  1. Path: ipdyne44.vir.com!optimal
  2. From: optimal@vir.com (optimal)
  3. Newsgroups: comp.lang.c
  4. Subject: sequence pts wrt pointer dereferencing
  5. Date: Fri, 5 Jan 1996 15:52:31 UNDEFINED
  6. Organization: Communications Vir
  7. Message-ID: <optimal.8.7116A605@vir.com>
  8. NNTP-Posting-Host: ipdyne44.vir.com
  9. Keywords: sequence points expression evaluation
  10. X-Newsreader: Trumpet for Windows [Version 1.0 Rev B final beta #4]
  11.  
  12. For reasons of virtual memory swapping, we have what amounts to the following:
  13.  
  14. int* A (int i)
  15.    {
  16.    static int x;
  17.  
  18.    x = i;
  19.    return &x;
  20.    }
  21.  
  22. foo ( )
  23.    {
  24.    .....
  25.    *A(1) += *A(100);
  26.    }
  27.  
  28. This fails due to the value *A(100) not being stored before the *A(1) is 
  29. evaulated. The following works:
  30.  
  31.    int tmp = *A(100);
  32.    *A(1) += tmp;
  33.  
  34. Is there another alternative to the use of tmp variables?
  35.  
  36.